package com.sean.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sean.chart.ChartConfiguration;
import com.sean.dao.IUserDao;

@Controller
@RequestMapping("/chart.do")
public class ChartController {

    // DI by type
    @Autowired
    private IUserDao userDao;

    @Autowired
    private ChartConfiguration chartConfiguraion;

    public ChartConfiguration getChartConfiguraion() {
	return chartConfiguraion;
    }

    public void setChartConfiguraion(ChartConfiguration chartConfiguraion) {
	this.chartConfiguraion = chartConfiguraion;
    }

    @RequestMapping
    public ModelAndView chartHere(HttpServletRequest resq,
	    HttpServletResponse resp) {
	System.out.println("call listAllBoard method.");
	ModelMap modelMap = new ModelMap();
	modelMap.addAttribute("resultSymbol", "success");
	System.out.println("Configuration:"
		+ getChartConfiguraion().getClientMax());
	modelMap.addAttribute("clientmax", getChartConfiguraion()
		.getClientMax());
	// modelMap.addAttribute("user", user);
	// modelMap.addAttribute("editable", myObject.isEditable());
	// modelMap.addAttribute("updater", anotherObject);
	ModelAndView mav = new ModelAndView("chartpage", modelMap);
	System.out.println(resq.getRequestURI());
	System.out.println(resq.getParameter("index"));
	return mav;
    }
}
